<CFSET sMessPostApproval="Employee has been successfully registered for this training event.">
<CFQUERY NAME="qryCINTRAINING" DATASOURCE="#client.company_dsn#">
	SELECT *
	FROM CINTRAINING
	WHERE ROUTEID = '#GetRecord.ROUTEID#'
</CFQUERY>

<CFIF qryCINTRAINING.RecordCount>
	<!--- Check if employee is already in the list of attendees --->
	<CFQUERY NAME="qryCINTRNGATTENDIS" DATASOURCE="#client.company_dsn#">
		SELECT TRAININGEVENTNUM
		FROM CINTRNGATTENDIS
		WHERE TRAININGEVENTNUM = '#qryCINTRAINING.TRAININGEVENTNUM#'
	</CFQUERY>

	<CFIF NOT qryCINTRNGATTENDIS.RecordCount>
		<!--- Check training event --->
		<CFQUERY NAME="qryCINTRNGEVENT" DATASOURCE="#client.company_dsn#">
			SELECT NOOFDAYS, HOURSPERDAY
			FROM CINTRNGEVENT
			WHERE TRAININGEVENTNUM = '#qryCINTRAINING.TRAININGEVENTNUM#'
		</CFQUERY>
	
		<CFIF qryCINTRNGEVENT.RecordCount>
			<!---
			<CFSET nNoofHrs=0>
			<CFIF qryCINTRNGEVENT.NOOFDAYS NEQ "" AND qryCINTRNGEVENT.HOURSPERDAY NEQ "">
				<CFSET nNoofHrs=qryCINTRNGEVENT.NOOFDAYS * qryCINTRNGEVENT.HOURSPERDAY>
			</CFIF>
			--->
			
			<CFTRANSACTION>
			<CFTRY>				
				<CFQUERY NAME="qryRegisterNow" DATASOURCE="#client.company_dsn#">
					INSERT INTO CINTRNGATTENDIS
						(TRAININGEVENTNUM, PERSONNELIDNO)
					VALUES
						('#qryCINLEAVEAPPSI.TRAININGEVENTNUM#', '#qryCINLEAVEAPPSI.PERSONNELIDNO#')
				</CFQUERY>
				
				<CFTRANSACTION ACTION="COMMIT"/>						
				<CFCATCH TYPE="Database">
					<CFTRANSACTION ACTION="ROLLBACK"/>
					<CFSET sMessPostApproval="Error in post-approval activity ...<br><br>#CFCATCH.message# #CFCATCH.DETAIL#">
				</CFCATCH> 
			</CFTRY>
			</CFTRANSACTION>				
		<CFELSE>
			<CFSET sMessPostApproval="WARNING!!! Unable to register employee. Training event is missing.<BR>Please contact your administrator.">
		</CFIF>	<!--- Training Event not found in CINTRNGEVENT --->
	<CFELSE>
		<CFSET sMessPostApproval="ERROR!!! Employee is already in the list.">
	</CFIF>	<!--- Training Event not found in CINTRNGEVENT --->
<CFELSE>
	<CFSET sMessPostApproval="WARNING!!! Unable to register employee. Registration form is missing.<BR>Please contact your administrator.">
</CFIF> <!--- RouteID not found in CINTRAINING --->